// pages/termAdd/index.js
import { request } from '../../request/index'
Page({
  data: {
    multiIndex: [0, 0, 0],
    region: ['广东省', '广州市', '海珠区'],
    customItem: '全部',
    name: '',

  },
  bindRegionChange: function (e) {
    this.setData({
      region: e.detail.value
    })
  },
  nameInput: function (e) {
    this.setData({ name: e.detail.value })
  },

  addPlace: function () {
    var app = getApp()
    var data = {
      name: this.data.name,
      place: this.data.region.join(','),
      imgUrl: '',
    }
    request({ url: app.globalData.root + 'api/placeAdd', data: data, dataType: 'json', method: 'POST' }).then((res) => {
      wx.showToast({
        title: '添加成功',
        icon: 'success',
        duration: 2000,
        complete: function () {
          var timeId = setTimeout(() => {
            clearTimeout(timeId)
            wx.navigateBack({
              delta: 1
            })
          }, 2000);
        }
      })
    })
  }
})